namespace Terra.Core.Configuration.Options
{
    /// <summary>
    /// 日志配置
    /// </summary>
    public class LogSettings
    {
        /// <summary>
        /// 最小日志级别(Trace/Debug/Information/Warning/Error/Critical)
        /// </summary>
        public string MinimumLevel { get; set; } = "Information";

        /// <summary>
        /// 是否启用控制台日志
        /// </summary>
        public bool EnableConsole { get; set; } = true;

        /// <summary>
        /// 文件日志配置
        /// </summary>
        public FileLogSettings File { get; set; } = new();

        /// <summary>
        /// Elasticsearch日志配置
        /// </summary>
        public ElasticsearchLogSettings Elasticsearch { get; set; } = new();
    }

    /// <summary>
    /// 文件日志配置
    /// </summary>
    public class FileLogSettings
    {
        /// <summary>
        /// 是否启用文件日志
        /// </summary>
        public bool Enable { get; set; } = true;

        /// <summary>
        /// 日志文件路径
        /// </summary>
        public string Path { get; set; } = "logs/log-.txt";

        /// <summary>
        /// 单个文件大小限制(MB)
        /// </summary>
        public int FileSizeLimitMB { get; set; } = 10;

        /// <summary>
        /// 日志保留天数
        /// </summary>
        public int RetainedDays { get; set; } = 30;

        /// <summary>
        /// 是否按日期分割文件
        /// </summary>
        public bool RollingByDate { get; set; } = true;

        /// <summary>
        /// 是否按大小分割文件
        /// </summary>
        public bool RollingBySize { get; set; } = true;
    }

    /// <summary>
    /// Elasticsearch日志配置
    /// </summary>
    public class ElasticsearchLogSettings
    {
        /// <summary>
        /// 是否启用Elasticsearch日志
        /// </summary>
        public bool Enable { get; set; } = false;

        /// <summary>
        /// Elasticsearch连接URL
        /// </summary>
        public string Url { get; set; } = "http://localhost:9200";

        /// <summary>
        /// 索引名称格式
        /// </summary>
        public string IndexFormat { get; set; } = "terra-logs-{0:yyyy.MM}";

        /// <summary>
        /// 用户名
        /// </summary>
        public string Username { get; set; } = "";

        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; } = "";
    }
}